﻿using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.Mvc;

namespace FogBugzPd.Web.Utils
{
	public static class HtmlGenerationUtils
	{
		public static HtmlString GenerateHolidaysTable(this IEnumerable<Holiday> holidays)
		{
			var builder = new StringBuilder();

			builder.Append(@"<table class=""table"">");

			foreach (var holiday in holidays)
			{
				builder.Append("<tr>");

				builder.Append("<td>");

				builder.Append(HttpUtility.HtmlEncode(holiday.Date.FormatShortDate()).Replace(" ", "&nbsp;"));

				builder.Append("</td>");

				builder.Append("<td>");

				builder.Append(HttpUtility.HtmlEncode(holiday.Description).Replace(" ", "&nbsp;"));

				builder.Append("</td>");

				builder.Append("</tr>");
			}

			builder.Append("</table>");

			return MvcHtmlString.Create(builder.ToString());
		}
	}
}
